{extend name="base"/}
{block name="css"}


<link rel="stylesheet" href="__ADMIN__/css/treestyle.css">

{/block}
{block name="content"}


<div style="padding: 15px;">
    <fieldset class="layui-elem-field">
        <legend>会员管理 - 推荐结构</legend>
        <div class="layui-field-box">
            <form  class="layui-form"  action="{:url('/backend/user/jiegou')}" method="post">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input name="id" type="text" class="layui-input searchUser" placeholder="请输入搜索的UID">
                    </div>
                    <button  class="layui-btn search_btn" type="submit">搜索</button>
                </div>
              </form>
          <hr>
          <div class="tab-content ct-tab-content">
            <div class="panel-body">
                <div class="builder formbuilder-box">
                    <!-- 数据列表 -->
                    <div class="builder-container">
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="builder-table">
                                    <div class="panel panel-default table-responsive">
                                        <!-- 树 -->
                                        <ul id="treeid" class="tree">
    
                                          <li id="treeid_1" treenode="">
                                           <!--  <button type="button" id="treeid_1_switch" title="" class="switch_center_close" treenode_switch="" onfocus="this.blur();"></button> -->
                                            <a id="treeid_1_a" treenode_a="" onclick="" target="_blank" data-href="123">
                                                <button type="button" id="treeid_1_ico" title="" treenode_ico="" onfocus="this.blur();" class=" ico_open"></button>
                                                <span id="treeid_1_span" {if $my != ''} class="edits" data-src="{:url('/backend/User/editUser',['id'=>$my['id']])}" }{else/}{/if} >{if $my != ''}{$my['mobile']}{else/}one{/if}</span>
                                            </a>
                                            <?php if(count($users) > 0){ ?>
                                            <ul id="treeid_1_ul" class="" style="display: block;">
                                                <?php 
                                                $i = 1;
                                                foreach ($users as $k => $tree):
                                                    $i++;
                                                ?>
                                                <li id="treeid_<?=$i?>" treenode="">
                                                    <button onclick="javascript:showTree(this,'<?=$tree->id?>')" type="button" id="treeid_<?=$i?>_switch" title="" class="switch_center_close" treenode_switch="" onfocus="this.blur();"></button>
                                                    <a href="javascript:;" id="treeid_<?=$i?>_a" treenode_a="" target="_blank">
                                                        <button type="button" id="treeid_<?=$i?>_ico" title="" treenode_ico="" onfocus="this.blur();" class=" ico_docu"></button>
                                                        <span id="treeid_<?=$i?>_span"  class="edits"  data-src="{:url('/backend/user/editUser',['id'=>$tree['id']])}"><?=$tree->mobile?></span>
                                                    </a> 
                                                    <ul id="treeid_<?=$i?>_ul" class="line" style="display: none"></ul>
                                                </li>
                                                <?php endforeach; ?>
                                            </ul>
                                            <?php }?>
                                          </li>
    
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>                   
    

        </div>
    </fieldset>
  </div>






{/block}
{block name="js"}
<script>
        function showTree(obj,munumber){
         if($(obj).attr('class') == 'switch_center_close'){
             $(obj).attr('class','switch_center_open');
             $.ajax({
                 type: "POST",
                 url:"{:url('/backend/user/tree')}",
                 data:'id='+munumber,
                 dataType:'json',
                 success:function(tree){
                    // //console.log(tree);
                     if(tree.length > 0){
                         var ulstr = '';
                         for(var i = 0;i<tree.length;i++){
                             ulstr += '<li  treenode=""><button type="button" onclick="javascript:showTree(this,\''+tree[i].id+ '\')" title="" class="switch_center_close" treenode_switch="" onfocus="this.blur();"></button><a onclick="" style=""><button type="button"   title="" treenode_ico="" onfocus="this.blur();" class=" ico_docu" style=""></button><span class="edits"  data-src="/admin/User/editUser/id/'+tree[i].id+'">'+ tree[i].mobile +'</span></a><ul class="line" style="display: none"></ul></li>';
                         }
                         $(obj).parent().find('ul').attr('style','display:block');
                         $(obj).parent().find('ul').append(ulstr);
                     }
                 },
             });
         }else if($(obj).attr('class') == 'switch_center_open'){
             $(obj).attr('class','switch_center_close');
             $(obj).parent().find('ul').html('');
         }
      }
</script>
{/block}

